<!-- 商品审核 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label mb10">
            商品审核

        </p>
        <div>
            <dxtable :headBtn="headBtn" :dataJson="dataJson" :portUrl="portUrl" :qx="qx" ref="databale"
                sonRouter="xqaddproduct" :hidebj="true"></dxtable>
        </div>
    </div>
</template>
<script lang='ts' setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf, callBack } from "../../util/index";
import { NButton } from "naive-ui"
import { h, ref, reactive } from "vue";
const props = defineProps({
    pup: { type: String },
});
let headBtn = [];
const databale = ref();
const cz = qurl()
const initeer = () => {
    databale.value.initDataExpose();
};
const emit = defineEmits(["callBack"]);
const classifyoptions = ref()
const gysList = ref()
const optionsa = ref()
// 弹窗公用该列表
const url = "xqts/xqcommodityManagement"
let dataJson = reactive([

    {
        title: "缩略图",
        search: true, // 是否在搜索栏展示
        key: "cover",
        width: 80,
        render(row) {
            return h("img", { src: row.cover, class: "spfmimgserr" })
        }
    },
    {
        title: "供应商名称",
        search: true, // 是否在搜索栏展示
        key: "name",
    },
    {
        title: "规格",
        width: 100,
        search: true, // 是否在搜索栏展示
        key: "specification",
    },
    {
        title: "分类",
        width: 140,
        search: true, // 是否在搜索栏展示
        key: "classification",
        options: [],
        type: "select",
        render(row) {
            try {
                return optionsa.value.filter(a => a.value == row.classification)[0].label
            } catch (e) {

            }
        }
    },
    {
        title: "单价",
        width: 90,
        key: "price",
    },
    {
        title: "库存",
        width: 50,
        key: "inventory",
    },



    {
        title: "审核状态",
        key: "auditStatus",
        type: "select",
        search: true, // 是否在搜索栏展示
        width: 160,
        options: [
            {
                label: "全部",
                value: ""
            }, {
                label: "等待审核",
                value: "1"
            }, {
                label: "审核通过",
                value: "2"
            }, {
                label: "审核不通过",
                value: "3"
            }
        ],
        render(row) {
            if (row.auditStatus == 1) {
                return h("span", { class: "" }, "审核中")
            }
            if (row.auditStatus == 2) {
                return h("span", { class: "ls" }, "审核通过")
            }
            if (row.auditStatus == 3) {
                return h("span", { class: "z9" }, "审核不通过(" + row.AuditRemarks + ")")
            }
        }

    },
    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "xqcommodityManagement";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "创建时间",
        key: "addTime",
        width: "200",
        type: "daterange",
    },
    {
        title: "操作",
        width: "140",
        align: "center",
        render(row) {
            const arr = localStorage.rolemanagement.split(",");
            const czBtn = [];
            czBtn.push(
                h(
                    NButton,
                    {
                        type: "info",
                        quaternary: true,
                        onClick: () => {
                            hf('xqaddproduct', { id: row.id, sh: 2 })
                        },
                    },
                    "点击审核"
                )
            );

            return czBtn;
        },
    }


]);
let portUrl = url;
const qx = {
    DeletePermissionID: "xqsupplierdel", //删除
    EditPermissionIdentifier: "xqsupplierbj", // 编辑
    NewPermissionIdentifier: "xqsupplierxz", // 新建
    ViewPermissionID: "xqsupplierck", // 查看
};


let pupVal = props.pup;
if (pupVal) {
    headBtn = [
        {
            name: "确认选择 ",
            async clickFun(row) {
                const arrList = row.join(",");
                emit("callBack", arrList);
            },
        },
    ];



}
// const getcyyxconfig = async () => {
//     const { data }: any = await dxget('xqts/getarea')
//     classifyoptions.value = data
// }
// getcyyxconfig()
// const getarea = async () => {
//     const { data }: any = await dxget('public/area')
//     dataJson[1].options= data
// }
// getarea()

const getzdise = async () => {
    const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xqclassificationGoods' })
    optionsa.value = data
    dataJson[3].options = [
        {
            label: "全部",
            value: ""
        },
        ...data
    ]
}

getzdise()



</script>


